<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2016/9/22
 * Time: 10:19
 */
date_default_timezone_set('PRC');
$file = $_GET['filename'];
$fname = pathinfo($file, PATHINFO_FILENAME);
$Ftype = strtolower(substr(strrchr($file, '.'), 1));
downfile($file, $fname, $Ftype);
function downfile($file, $fname, $ft)
{
    $filename = realpath(dirname(__FILE__) . '/download_files/' . $file); //文件名
    Header("Content-type:  application/octet-stream ");
    Header("Accept-Ranges:  bytes ");
    Header("Accept-Length: " . filesize($filename));
    header("Content-Disposition:  attachment;  filename= {$fname}.{$ft}");
    die(file_get_contents($filename));
    readfile($filename);
}

